﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WebGetter
{
    public static class UrlHelper
    {
        public static string GetFullUrlWithBaseUrl(string currUrl, string sampleUrl)
        {
            string result = "";
            string baseUrl = new RegexHelper(sampleUrl).GetSingleStringByRegexp("(?<val>https?://[^/]+)");
            if (string.IsNullOrEmpty(currUrl))
            {
                result = string.Empty;
            }
            else if (!currUrl.StartsWith("http://"))
            {
                result = baseUrl + "/" + currUrl.TrimStart('/');
            }
            else
            {
                result = currUrl;
            }
            return result;
        }
    }
}
